/*  --------------------------- (C) COPYRIGHT 2020 Fortiortech ShenZhen -----------------------------
    File Name      : PIInit.c
    Author         : Fortiortech  Appliction Team
    Version        : V1.0
    Date           : 2020-04-11
    Description    : This file contains PI initial function used for Motor Control.
    ----------------------------------------------------------------------------------------------------
                                       All Rights Reserved
    ------------------------------------------------------------------------------------------------- */
/* Includes -------------------------------------------------------------------------------------*/
#include "Myproject.h"
void PI0_Init(void)
{
    PI0_KP  = SKP;
    PI0_KI  = SKI;
    PI0_UKH = 0;
    PI0_UKL = 0;
    PI0_EK  = 0;
    PI0_EK1 = 0;
    PI0_UKMAX = SOUTMAX;
    PI0_UKMIN = SOUTMIN;
    SetBit(PI_CR , PI0STA);          // Start PI
    while (ReadBit(PI_CR , PIBSY));
}

void PI1_Init(void)
{
    PI1_KP  = SKP;
    PI1_KI  = SKI;
    PI1_UKH = 0;
    PI1_UKL = 0;
    PI1_EK  = 0;
    PI1_EK1 = 0;
    PI1_UKMAX = SOUTMAX;
    PI1_UKMIN = SOUTMIN;
    SetBit(PI_CR , PI1STA);          // Start PI
    while (ReadBit(PI_CR , PIBSY));
}
/*  ----------------------------------------------------------------------------------------------*/
/*  Function Name  : PI2_Init
    /*  Description    : 功率环参数初始化
    /*  Date           : 2021-03-22
    /*  Parameter      : None
    /*  ----------------------------------------------------------------------------------------------*/
void PI2_Init(void)
{
    PI2_KP  = 1;
    PI2_KI  = 1;
    PI2_UKH = 0;
    PI2_UKL = 0;
    PI2_EK  = 0;
    PI2_EK1 = 0;
    PI2_KD = 0;
    PI2_EK2 = 0;
    PI2_UKMAX = 1<<3;
    PI2_UKMIN = 1<<3;
    SetBit(PI_CR , PI2STA);          // Start PI
    while (ReadBit(PI_CR , PIBSY));
}
/*  ----------------------------------------------------------------------------------------------*/
/*  Function Name  : PI3_Init
    /*  Description    : 速度环参数初始化
    /*  Date           : 2021-03-22
    /*  Parameter      : None
    /*  ----------------------------------------------------------------------------------------------*/
void PI3_Init(void)
{
    PI3_KP  = SKP;
    PI3_KI  = SKI;
    PI3_UKH = 0;
    PI3_UKL = 0;
    PI3_EK  = 0;
    PI3_EK1 = 0;
    PI3_KD =  0;
    PI3_EK2 = 0;
    PI3_UKMAX = SOUTMAX;  //最大限幅外部设置
    PI3_UKMIN = SOUTMIN;
    SetBit(PI_CR, PI3STA);           // Start PI
    while (ReadBit(PI_CR, PIBSY));
}
